#include <bits/stdc++.h>
// 2025/02/07
// tag:
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;
#define dis(x, y) sqrt((pos[x][0] - pos[y][0]) * (pos[x][0] - pos[y][0]) + (pos[x][1] - pos[y][1]) * (pos[x][1] - pos[y][1]))
int n, pos[151][2], vis[151], cnt;
double floyd[151][151], r[151];

vector<int> g[151], e[151];

void dfs(int i){
    if (vis[i])
        return;
    vis[i] = 1;
    g[cnt].push_back(i);
    for (auto j : e[i])
        dfs(j);
}

double help(int i, int j){
    double ans = INT_MAX;
    for (auto x : g[i])
        for (auto y: g[j]){
            double ans1 = 0, ans2 = 0;
            for (auto k: g[i])
                ans1 = max(ans1, floyd[x][k]);
            for (auto k: g[j])
                ans2 = max(ans2, floyd[y][k]);
            ans = min(ans, ans1 + ans2 + dis(x, y));
        }
    return max(ans, max(r[i], r[j]));
}

void init(int i){
    double ans = 0;
    for (int j = 0; j < g[i].size(); j++)
        for (int k = j + 1; k < g[i].size(); k++)
            ans = max(ans, floyd[g[i][j]][g[i][k]]);
    r[i] = ans;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> pos[i][0] >> pos[i][1];
    for (int i = 1; i <= n; i++){
        string s;
        cin >> s;
        for (int j = 1; j <= n; j++) {
            if (s[j - 1] == '1')
                floyd[i][j] = dis(i, j), e[i].push_back(j);
            else
                floyd[i][j] = INT_MAX;
        }
        floyd[i][i] = 0;
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            for (int k = 1; k <= n; k++)
                floyd[j][k] = min(floyd[j][k], floyd[j][i] + floyd[i][k]);
    for (int i = 1; i <= n; i++){
        if (!vis[i]){
            cnt++;
            dfs(i);
        }
    }
    for (int i = 1; i <= cnt; i++)
        init(i);
    double ans = INT_MAX;
    for (int i = 1; i <= cnt; i++)
        for (int j = i + 1; j <= cnt; j++)
            ans = min(ans, help(i, j));
    cout << fixed << setprecision(6) << ans << endl;
    return 0;
}